package com.syf.enums;

/**
 * 【3】枚举类：
 *          标识订单是 卖出/买入
 */
public enum OrderDirection {

    BUY(1,"买入") ,
    SELL(2,"卖出") ;

    private int code ;

    private String desc ;


    OrderDirection(int code,String desc){
        this.code = code ;
        this.desc = desc ;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    //根据code 获取 订单描述对象
    public static OrderDirection getOrderDirection(int code){
        OrderDirection[] values = OrderDirection.values();  //"1 买入/  2 卖出"
        for (OrderDirection orderDirection : values) {
            if(orderDirection.getCode()==code){
                return orderDirection ;
            }
        }
        return null ;
    }
}
